﻿#region

using FluentNHibernate.Mapping;

#endregion

namespace MediaSage.Lib.Database
{
    public class VideoMap : ClassMap<VideoEntity>
    {
        #region Constructors

        public VideoMap()
        {
            Table("VideoInfo");
            Map(x => x.Filename);
            Id(x => x.ID).GeneratedBy.GuidComb().UnsavedValue("00000000-0000-0000-0000-000000000000");
            Map(x => x.Adult);
            HasManyToMany(x => x.SimilarItems).Table("VideoSimilarItems").ParentKeyColumn("SimilarItemsPK").
                ChildKeyColumn("VideoEntityPK").Cascade.All();
            HasMany(x => x.AltNames).Element("AltNames").Cascade.All();
            Map(x => x.AudioBitrate);
            Map(x => x.AudioChannels);
            Map(x => x.AudioCodec);
            Map(x => x.AudioCodecRaw);
            Map(x => x.AudioFrequency);
            Map(x => x.Budget);
            HasMany(x => x.Cast).Cascade.All().Table("People");
            HasMany(x => x.Categories).Element("Categories").Cascade.All();
            HasMany(x => x.Certifications).Cascade.All().Table("Certifications");
            HasMany(x => x.Countries).Element("Countries").Cascade.All();
            HasMany(x => x.Distributors).Element("Distributors").Cascade.All();
            Map(x => x.DVDId).CustomSqlType("ntext");
            HasMany(x => x.Episodes).Cascade.All().Table("Episodes");
            HasMany(x => x.Genre).Element("Genre").Cascade.All();
            HasOne(x => x.Poster).Cascade.All();
            HasOne(x => x.Backdrop).Cascade.All();
            HasManyToMany(x => x.Images).Table("VideoImages").ParentKeyColumn("ImagesPK").ChildKeyColumn("VideoImagePK")
                .Cascade.All();
            Map(x => x.IMDBID);
            Map(x => x.IsFinale);
            Map(x => x.isPremire);
            Map(x => x.IsRepeat);
            Map(x => x.IsTVSeries);
            HasMany(x => x.Languages).Element("Languages").Cascade.All();
            Map(x => x.LastModified).Nullable();
            Map(x => x.MPAARating);
            Map(x => x.Name);
            Map(x => x.Overview).CustomSqlType("ntext");
            Map(x => x.Popularity).CustomSqlType("float");
            Map(x => x.Rating).CustomSqlType("float");
            Map(x => x.Released).Nullable();
            Map(x => x.Revenue);
            Map(x => x.RunTime);
            Map(x => x.Score).CustomSqlType("float");
            HasMany(x => x.SeriesAirsDaysOfWeek).Element("AirsOn").Cascade.All();
            Map(x => x.SeriesAirsTime).Nullable();
            Map(x => x.SeriesID);
            HasMany(x => x.Studios).Element("Studios").Cascade.All();
            Map(x => x.isSubtitled);
            Map(x => x.TmdbID);
            Map(x => x.Trailer);
            Map(x => x.Translated);
            Map(x => x.TvdbID);
            Map(x => x.URL);
            Map(x => x.VideoAspect);
            Map(x => x.VideoBitrate);
            Map(x => x.VideoCodec);
            Map(x => x.VideoCodecVersion);
            Map(x => x.VideoFilesize);
            Map(x => x.VideoHeight);
            Map(x => x.VideoFrameRate);
            Map(x => x.VideoLength);
            Map(x => x.VideoQuality);
            Map(x => x.VideoWidth);
            Map(x => x.Description).CustomSqlType("ntext");
            Map(x => x.StationName);
            Map(x => x.FileSize);
            HasMany(x => x.Metadata).Cascade.All().Table("Metadata");
            Map(x => x.AudioSAP);
            Map(x => x.IsDelay);
            Map(x => x.IsLive);
            Map(x => x.IsMovie);
            Map(x => x.IsSAP);
            Map(x => x.IsSport);
            Map(x => x.NetworkAffiliation);
            Map(x => x.OriginalBroadcastTime).Nullable();
            Map(x => x.ParentalRating);
            Map(x => x.Subtitle);
            Map(x => x.ContentProtected);
            Map(x => x.IsHDContent);
            Map(x => x.VideoBitRateMode);
            Map(x => x.RottenTomatosID);
        }

        #endregion Constructors
    }
}